package com.cqut.forum.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author yangxun
 * UserGroup entity
 */
@Entity
@Table(name = "user_group", catalog = "forum")
public class UserGroup implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer groupId;
	private Integer groupOwner;
	private Date groupBuildTime;
	private String groupName;
	private Integer groupNumber;
	private String groupNotes;
	private String groupKind;
	private Set<GroupRelation> groupRelations = new HashSet<GroupRelation>(0);

	// Constructors

	/** default constructor */
	public UserGroup() {
	}

	/** full constructor */
	public UserGroup(Integer groupOwner, Date groupBuildTime, String groupName,
			Integer groupNumber, String groupNotes, String groupKind,
			Set<GroupRelation> groupRelations) {
		this.groupOwner = groupOwner;
		this.groupBuildTime = groupBuildTime;
		this.groupName = groupName;
		this.groupNumber = groupNumber;
		this.groupNotes = groupNotes;
		this.groupKind = groupKind;
		this.groupRelations = groupRelations;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "group_id", unique = true, nullable = false)
	public Integer getGroupId() {
		return this.groupId;
	}

	public void setGroupId(Integer groupId) {
		this.groupId = groupId;
	}

	@Column(name = "group_ower")
	public Integer getGroupOwner() {
		return groupOwner;
	}

	public void setGroupOwner(Integer groupOwner) {
		this.groupOwner = groupOwner;
	}

	//@Temporal(TemporalType.DATE)
	@Column(name = "group_build_time", length = 10)
	public Date getGroupBuildTime() {
		return this.groupBuildTime;
	}

	public void setGroupBuildTime(Date groupBuildTime) {
		this.groupBuildTime = groupBuildTime;
	}

	@Column(name = "group_name", length = 20)
	public String getGroupName() {
		return this.groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	@Column(name = "group_number")
	public Integer getGroupNumber() {
		return this.groupNumber;
	}

	public void setGroupNumber(Integer groupNumber) {
		this.groupNumber = groupNumber;
	}

	@Column(name = "group_notes", length = 100)
	public String getGroupNotes() {
		return this.groupNotes;
	}

	public void setGroupNotes(String groupNotes) {
		this.groupNotes = groupNotes;
	}

	@Column(name = "group_kind", length = 20)
	public String getGroupKind() {
		return this.groupKind;
	}

	public void setGroupKind(String groupKind) {
		this.groupKind = groupKind;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "userGroup")
	public Set<GroupRelation> getGroupRelations() {
		return this.groupRelations;
	}

	public void setGroupRelations(Set<GroupRelation> groupRelations) {
		this.groupRelations = groupRelations;
	}

}